package dep_db

import (
	"feng-che.com/server/driver-quiz/myApp"
	"fmt"
	"go.mongodb.org/mongo-driver/mongo"
)

func UsedDB() *mongo.Database {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	dbName := myApp.AppSetting.Mongo.DBName
	maindb := MainDB.DBConnInstance.Database(dbName)
	if maindb == nil {
		panic("数据库没有链接")
	}
	return maindb
}

// ObjectCollection 集合方法
func ObjectCollection(collName *string) *mongo.Collection {
	return UsedDB().Collection(*collName)
}

func OrderCollection() *mongo.Collection {
	name := "order"
	return ObjectCollection(&name)
}

func CartCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func ServiceModelCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func SkuCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func SpuServiceCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func SkuServiceCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func RestrictionOnUseCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func TicketActiveStudyRecord() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func GoodModelCollection() *mongo.Collection {
	name := "cart"
	return ObjectCollection(&name)
}

func ClientCollection() *mongo.Collection {
	name := "client"
	return ObjectCollection(&name)
}

func CallLineUpCollection() *mongo.Collection {
	name := "client1"
	return ObjectCollection(&name)
}

func TicketTemplateCollection() *mongo.Collection {
	name := "client2"
	return ObjectCollection(&name)
}

func TicketDeliveryCollection() *mongo.Collection {
	name := "client3"
	return ObjectCollection(&name)
}

func RestrictionUpdateByGoodCollection() *mongo.Collection {
	name := "client4"
	return ObjectCollection(&name)
}
